package cn.edu.stu.syllabus.oa.detail;

import cn.edu.stu.syllabus.api.OaFileApi;
import cn.edu.stu.syllabus.dao.OaInfoEntryDao;
import cn.edu.stu.syllabus.repository.oa.OaStarDataSource;
import cn.edu.stu.syllabus.repository.oa.local.OaInfoEntry;
import cn.edu.stu.syllabus.repository.oa.local.OaStarLocalDataSource;
import cn.edu.stu.syllabus.repository.oaFile.OaFileDataSource;
import cn.edu.stu.syllabus.repository.oaFile.remote.OaFileRemoteDataSource;
import cn.edu.stu.syllabus.di.qualifier.Local;
import cn.edu.stu.syllabus.di.qualifier.Remote;
import cn.edu.stu.syllabus.di.scope.FragmentScoped;
import cn.edu.stu.syllabus.utils.GreenDaoUtils;
import cn.edu.stu.syllabus.utils.OaRetrofit;
import dagger.Module;
import dagger.Provides;

/**
 * Created by daidaijie on 2017/3/18.
 */

@Module
public class OaDetailPresenterModule {

    private final OaDetailContract.View mView;

    private final OaInfoEntry mOaInfoEntry;

    public OaDetailPresenterModule(OaDetailContract.View view, OaInfoEntry oaInfoEntry) {
        mView = view;
        mOaInfoEntry = oaInfoEntry;
    }

    @FragmentScoped
    @Provides
    OaDetailContract.View provideView() {
        return mView;
    }

    @FragmentScoped
    @Provides
    OaInfoEntry provideOaInfoEntry() {
        return mOaInfoEntry;
    }

    @FragmentScoped
    @Provides
    OaInfoEntryDao provideOaInfoEntryDao() {
        return GreenDaoUtils.getInstance().getSession().getOaInfoEntryDao();
    }

    @FragmentScoped
    @Provides
    @Local
    OaStarDataSource provideOaLocalDataSource(OaInfoEntryDao oaInfoEntryDao) {
        return new OaStarLocalDataSource(oaInfoEntryDao);
    }

    @FragmentScoped
    @Provides
    @Remote
    OaFileDataSource provideOaFileRemoteDataSource(OaFileApi oaFileApi) {
        return new OaFileRemoteDataSource(oaFileApi);
    }

    @FragmentScoped
    @Provides
    OaFileApi provideOaFileApi() {
        return OaRetrofit.getRetrofit().create(OaFileApi.class);
    }
}
